home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Glue to call UGLibrary in a code resource from a PPC application
- **
- ** by Jim Luther, Apple Developer Technical Support
- **
- ** File: PPCUGLibrary.c
- **
- ** Copyright © 1995 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes.
- */
-
- #include <Memory.h>
- #include <Resources.h>
- #include "UGLibraryGlue.h"
-
- static UGEntryPoints gUGEntryPoints;
- static Handle gUGLibraryHandle = NULL; /* initially set to NULL */
-
- /*
- ** Load the UGLibrary code resource and then initialize gUGEntryPoints.
- */
- static OSErr LoadUGLibrary(void)
- {
- OSErr result = noErr;
-
- /* If the UGLibrary code isn't loaded, load it now. */
- if ( gUGLibraryHandle == NULL )
- {
- gUGLibraryHandle = Get1Resource(kUGLibraryResType, kUGLibraryResID);
- if ( gUGLibraryHandle != NULL )
- {
- /*
- ** IMPORTANT NOTE: The stand-alone code resource is has the
- ** PRELOAD and LOCKED attributes set so I don't lock it here.
- */
-
- /* Set up the entry points structure */
- CallUniversalProc((UniversalProcPtr)*gUGLibraryHandle,
- uppMainEntryProcInfo, &gUGEntryPoints);
- }
- else
- {
- result = ResError();
- }
- }
- return ( result );
- }
-
- /*
- ** One routine for each defined in UGLibrary.h
- ** Each routine calls the appropriate UGLibrary function.
- **
- ** WARNING: UGOpenFile must be called from this code so that
- ** LoadUGLibrary is called to load the stand-alone
- ** code resource and initialize gUGEntryPoints.
- */
-
- pascal OSErr UGOpenFile(UserGroupPBPtr thePB, Boolean async)
- {
- OSErr result;
-
- result = LoadUGLibrary();
- if ( result == noErr )
- {
- result = CallUGProc(gUGEntryPoints.UGOpenFile, thePB, async);
- }
- return ( result );
- }
-
- pascal OSErr UGCloseFile(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGCloseFile, thePB, async) );
- }
-
- pascal OSErr UGCreateFile(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGCreateFile, thePB, async) );
- }
-
- pascal OSErr UGNewUser(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGNewUser, thePB, async) );
- }
-
- pascal OSErr UGDeleteUser(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGDeleteUser, thePB, async) );
- }
-
- pascal OSErr UGRenameUser(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGRenameUser, thePB, async) );
- }
-
- pascal OSErr UGGetUserInfo(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGGetUserInfo, thePB, async) );
- }
-
- pascal OSErr UGSetUserInfo(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGSetUserInfo, thePB, async) );
- }
-
- pascal OSErr UGAuthenticateUser(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGAuthenticateUser, thePB, async) );
- }
-
- pascal OSErr UGNewGroup(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGNewGroup, thePB, async) );
- }
-
- pascal OSErr UGDeleteGroup(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGDeleteGroup, thePB, async) );
- }
-
- pascal OSErr UGRenameGroup(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGRenameGroup, thePB, async) );
- }
-
- pascal OSErr UGGetGroupInfo(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGGetGroupInfo, thePB, async) );
- }
-
- pascal OSErr UGAssignUserToGroup(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGAssignUserToGroup, thePB, async) );
- }
-
- pascal OSErr UGDeleteUserFromGroup(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGDeleteUserFromGroup, thePB, async) );
- }
-
- pascal OSErr UGGetULInfo(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGGetULInfo, thePB, async) );
- }
-
- pascal OSErr UGSetULInfo(UserGroupPBPtr thePB, Boolean async)
- {
- return ( CallUGProc(gUGEntryPoints.UGSetULInfo, thePB, async) );
- }
-